import request from "@/api/request.js";

export const userSearchService = dataObj => {
  const params = new URLSearchParams();
  for (let key in dataObj) {
    if (key === "userId" && dataObj[key] === "") {
      params.append("userId", "-1");
    } else {
      params.append(key, dataObj[key]);
    }
  }
  let queryString = params.toString();
  let url = `/api-self/users/account/search?${queryString}`;
  return request.get(url);
};

export const classSearchService = dataObj => {
  const params = new URLSearchParams();
  for (let key in dataObj) {
    params.append(key, dataObj[key]);
  }
  let queryString = params.toString();
  let url = `/api-self/users/class/search?${queryString}`;
  return request.get(url);
};

export const unitSearchService = dataObj => {
  const params = new URLSearchParams();
  for (let key in dataObj) {
    params.append(key, dataObj[key]);
  }
  let queryString = params.toString();
  let url = `/api-self/users/unit/search?${queryString}`;
  return request.get(url);
};

export const tempSearchService = dataObj => {
  const params = new URLSearchParams();
  for (let key in dataObj) {
    params.append(key, dataObj[key]);
  }
  let queryString = params.toString();
  let url = `/api-self/inspection/search?${queryString}`;
  return request.get(url);
};

export const dataGroupSearchService = dataObj => {
  const params = new URLSearchParams();
  for (let key in dataObj) {
    params.append(key, dataObj[key]);
  }
  let queryString = params.toString();
  let url = `/api-self/inspection/data/search?${queryString}`;
  return request.get(url);
};
